package com.ruoyi.exam.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.exam.domain.entity.Question;
import com.ruoyi.exam.service.IQuestionService;

import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/exam/paper")
public class TPaperController {

    private final IQuestionService questionService;

    public TPaperController(IQuestionService questionService) {
        this.questionService = questionService;
    }

    @PostMapping("/generateQuestions")
    public AjaxResult generateQuestions(@RequestBody Map<String, Object> params) {
        List<String> titleNames = (List<String>) params.get("titleNames");
        Map<String, Integer> typeCount = (Map<String, Integer>) params.get("typeCount");

        List<Question> questions = questionService.generatePaperQuestions(titleNames, typeCount);
        return AjaxResult.success(questions);
    }
}